package com;

import com.fruits.Apple;
import com.fruits.Fruits;
import com.fruits.Mango;
import com.fruits.Strawberry;
import java.util.Scanner;

// @Slf4j 键盘输入提示我们后端可以用日志提示代替，println比较耗资源。
public class demo {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("购买苹果斤数为");
        int num_Apple = scanner.nextInt();
        System.out.println("购买草莓斤数为");
        int num_str = scanner.nextInt();
        System.out.println("购买芒果斤数为");
        int num_mango = scanner.nextInt();
        System.out.println("请选择题目");
        int s = scanner.nextInt();
        switch (s) {
            //第一第二题答案
            case 1:
            case 2:
            totalMoney(num_Apple, num_str, num_mango);
            break;
            //第三题答案
            case 3:
            dis_totalMoney(num_Apple, num_str, num_mango);
            break;
            //第四题答案
            case 4:
            sumMoney(num_Apple, num_str, num_mango);
            break;
        }

    }

    private static void totalMoney(int num_Apple, int num_str, int num_mango) {
        Fruits apple = new Apple();
        double apple_totalMoney = apple.totalMoney(num_Apple);
        Fruits strawberry = new Strawberry();
        double str_totalMoney = strawberry.totalMoney(num_str);
        Fruits mango = new Mango();
        double mango_totalMoney = mango.totalMoney(num_mango);
        double allMoney = apple_totalMoney + str_totalMoney + mango_totalMoney;
        System.out.println("总价格为" + allMoney);
    }

    private static void dis_totalMoney(int num_Apple, int num_str, int num_mango) {
        Fruits apple = new Apple();
        double apple_totalMoney = apple.totalMoney(num_Apple);
        Fruits strawberry = new Strawberry();
        double str_dis_totalMoney = strawberry.dis_totalMoney(num_str);
        Fruits mango = new Mango();
        double mango_totalMoney = mango.totalMoney(num_mango);
        double allMoney = apple_totalMoney + str_dis_totalMoney * 0.8 + mango_totalMoney;
        System.out.println("总价格为" + allMoney);
    }

    private static void sumMoney(int num_Apple, int num_str, int num_mango) {
        Fruits apple = new Apple();
        double apple_totalMoney = apple.totalMoney(num_Apple);
        Fruits strawberry = new Strawberry();
        double str_totalMoney = strawberry.totalMoney(num_str);
        Fruits mango = new Mango();
        double mango_totalMoney = mango.totalMoney(num_mango);
        double allMoney = apple_totalMoney + str_totalMoney + mango_totalMoney;
        if (allMoney > 100) {
            double m = allMoney / 100;
            m = Math.floor(m);
            double saveMoney = m * 10;
            allMoney = allMoney - saveMoney;
        }
        System.out.println("总价格为" + allMoney);
    }
}
